#include "LineEmitter.h"
#include "ParticleFlyweight.h"

CLineEmitter::CLineEmitter(void)
{
}


CLineEmitter::~CLineEmitter(void)
{
}

void CLineEmitter::SpawnParticles(int maxParticles,
							  float minPosX, float maxPosX, float minPosY, float maxPosY)
{
	if( maxParticles > 0)
		for(int i = 0; i <= maxParticles; ++i)
		{
			//float Life =(float)(rand()%((int)m_pFLW->MaxLife() - (int)m_pFLW->MinLife())+(int)m_pFLW->MinLife());
			float Life = CalcLifetime();
			float posX, posY;
			CalcEmitRange(minPosX,maxPosX,minPosY,maxPosY,posX,posY);

			m_LiveParticles.push_back(CParticle(Life,posX, posY,m_pFLW));
		}
}

void CLineEmitter::CalcEmitRange(float& minPosX, float& maxPosX, float& minPosY, float& maxPosY, float& endX, float& endY)
{

	endX =(float)(rand()%((int)maxPosX - (int)minPosX)+(int)minPosX);
	endY =(float)(rand()%((int)maxPosY - (int)minPosY)+(int)minPosY);
}